{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from glob import glob\n",
    "from IPython.display import display\n",
    "pd.set_option('display.max_columns', 99)\n",
    "pd.set_option('display.max_rows', 99)\n",
    "import EDA\n",
    "import utils\n",
    "#sorted(glob('../data/*'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 20/20 [00:14<00:00,  1.40it/s]\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SK_ID_PREV</th>\n",
       "      <th>SK_ID_CURR</th>\n",
       "      <th>NUM_INSTALMENT_VERSION</th>\n",
       "      <th>NUM_INSTALMENT_NUMBER</th>\n",
       "      <th>DAYS_INSTALMENT</th>\n",
       "      <th>DAYS_ENTRY_PAYMENT</th>\n",
       "      <th>AMT_INSTALMENT</th>\n",
       "      <th>AMT_PAYMENT</th>\n",
       "      <th>days_delayed_payment</th>\n",
       "      <th>amt_ratio</th>\n",
       "      <th>amt_delta</th>\n",
       "      <th>days_weighted_delay</th>\n",
       "      <th>days_weighted_delay_tsw3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2624024</th>\n",
       "      <td>1369693</td>\n",
       "      <td>100001</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4</td>\n",
       "      <td>-1619.0</td>\n",
       "      <td>-1628.0</td>\n",
       "      <td>17397.900</td>\n",
       "      <td>17397.900</td>\n",
       "      <td>9.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>4.6044</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3458712</th>\n",
       "      <td>1369693</td>\n",
       "      <td>100001</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>-1649.0</td>\n",
       "      <td>-1660.0</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>11.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>5.5220</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1478621</th>\n",
       "      <td>1369693</td>\n",
       "      <td>100001</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>-1709.0</td>\n",
       "      <td>-1715.0</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.9130</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2568722</th>\n",
       "      <td>1369693</td>\n",
       "      <td>100001</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>-1679.0</td>\n",
       "      <td>-1715.0</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>3951.000</td>\n",
       "      <td>36.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>36.0</td>\n",
       "      <td>17.4780</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3435373</th>\n",
       "      <td>1851984</td>\n",
       "      <td>100001</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4</td>\n",
       "      <td>-2856.0</td>\n",
       "      <td>-2856.0</td>\n",
       "      <td>3980.925</td>\n",
       "      <td>3980.925</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         SK_ID_PREV  SK_ID_CURR  NUM_INSTALMENT_VERSION  \\\n",
       "2624024     1369693      100001                     2.0   \n",
       "3458712     1369693      100001                     1.0   \n",
       "1478621     1369693      100001                     1.0   \n",
       "2568722     1369693      100001                     1.0   \n",
       "3435373     1851984      100001                     1.0   \n",
       "\n",
       "         NUM_INSTALMENT_NUMBER  DAYS_INSTALMENT  DAYS_ENTRY_PAYMENT  \\\n",
       "2624024                      4          -1619.0             -1628.0   \n",
       "3458712                      3          -1649.0             -1660.0   \n",
       "1478621                      1          -1709.0             -1715.0   \n",
       "2568722                      2          -1679.0             -1715.0   \n",
       "3435373                      4          -2856.0             -2856.0   \n",
       "\n",
       "         AMT_INSTALMENT  AMT_PAYMENT  days_delayed_payment  amt_ratio  \\\n",
       "2624024       17397.900    17397.900                   9.0        1.0   \n",
       "3458712        3951.000     3951.000                  11.0        1.0   \n",
       "1478621        3951.000     3951.000                   6.0        1.0   \n",
       "2568722        3951.000     3951.000                  36.0        1.0   \n",
       "3435373        3980.925     3980.925                   0.0        1.0   \n",
       "\n",
       "         amt_delta  days_weighted_delay  days_weighted_delay_tsw3  \n",
       "2624024        0.0                  9.0                    4.6044  \n",
       "3458712        0.0                 11.0                    5.5220  \n",
       "1478621        0.0                  6.0                    2.9130  \n",
       "2568722        0.0                 36.0                   17.4780  \n",
       "3435373        0.0                  0.0                    0.0000  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = utils.read_pickles('../data/installments_payments').sort_values(['SK_ID_CURR', 'DAYS_ENTRY_PAYMENT'], ascending=[True, False])\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "100%|██████████| 20/20 [00:03<00:00,  5.52it/s]\n"
     ]
    }
   ],
   "source": [
    "train = utils.load_train(['SK_ID_CURR', 'TARGET'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df = pd.merge(df, train, on='SK_ID_CURR', how='left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Shape: (13605401, 9)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>DataType</th>\n",
       "      <th>#Nulls</th>\n",
       "      <th>#Uniques</th>\n",
       "      <th>Min</th>\n",
       "      <th>Mean</th>\n",
       "      <th>Max</th>\n",
       "      <th>Std</th>\n",
       "      <th>top10 val</th>\n",
       "      <th>top10 cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>SK_ID_PREV</th>\n",
       "      <td>int64</td>\n",
       "      <td>0</td>\n",
       "      <td>997752</td>\n",
       "      <td>1000001.0</td>\n",
       "      <td>1.903365e+06</td>\n",
       "      <td>2843499.000</td>\n",
       "      <td>536202.905546</td>\n",
       "      <td>[2360056, 2592574, 1017477, 1449382, 1746731, ...</td>\n",
       "      <td>[293, 279, 248, 243, 236, 223, 222, 220, 219, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>SK_ID_CURR</th>\n",
       "      <td>int64</td>\n",
       "      <td>0</td>\n",
       "      <td>339587</td>\n",
       "      <td>100001.0</td>\n",
       "      <td>2.784449e+05</td>\n",
       "      <td>456255.000</td>\n",
       "      <td>102718.310411</td>\n",
       "      <td>[145728, 296205, 453103, 189699, 186851, 17269...</td>\n",
       "      <td>[372, 350, 347, 344, 337, 336, 332, 324, 323, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NUM_INSTALMENT_VERSION</th>\n",
       "      <td>float64</td>\n",
       "      <td>0</td>\n",
       "      <td>65</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.566373e-01</td>\n",
       "      <td>178.000</td>\n",
       "      <td>1.035216</td>\n",
       "      <td>[1.0, 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, ...</td>\n",
       "      <td>[8485004, 4082498, 620283, 237063, 55274, 4840...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>NUM_INSTALMENT_NUMBER</th>\n",
       "      <td>int64</td>\n",
       "      <td>0</td>\n",
       "      <td>277</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.887090e+01</td>\n",
       "      <td>277.000</td>\n",
       "      <td>26.664067</td>\n",
       "      <td>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</td>\n",
       "      <td>[1004160, 985716, 968279, 943502, 880007, 8279...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DAYS_INSTALMENT</th>\n",
       "      <td>float64</td>\n",
       "      <td>0</td>\n",
       "      <td>2922</td>\n",
       "      <td>-2922.0</td>\n",
       "      <td>-1.042270e+03</td>\n",
       "      <td>-1.000</td>\n",
       "      <td>800.946284</td>\n",
       "      <td>[-120.0, -180.0, -150.0, -119.0, -149.0, -210....</td>\n",
       "      <td>[11512, 11212, 11194, 11183, 11144, 11140, 111...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>DAYS_ENTRY_PAYMENT</th>\n",
       "      <td>float64</td>\n",
       "      <td>2905</td>\n",
       "      <td>3039</td>\n",
       "      <td>-4921.0</td>\n",
       "      <td>-1.051114e+03</td>\n",
       "      <td>-1.000</td>\n",
       "      <td>800.585883</td>\n",
       "      <td>[-91.0, -182.0, -154.0, -92.0, -245.0, -273.0,...</td>\n",
       "      <td>[13103, 13090, 13071, 12646, 12405, 12151, 119...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>AMT_INSTALMENT</th>\n",
       "      <td>float64</td>\n",
       "      <td>0</td>\n",
       "      <td>902539</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.705091e+04</td>\n",
       "      <td>3771487.845</td>\n",
       "      <td>50570.254429</td>\n",
       "      <td>[9000.0, 2250.0, 4500.0, 6750.0, 3375.0, 5625....</td>\n",
       "      <td>[254062, 179120, 174143, 173659, 149941, 96362...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>AMT_PAYMENT</th>\n",
       "      <td>float64</td>\n",
       "      <td>2905</td>\n",
       "      <td>944235</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.723822e+04</td>\n",
       "      <td>3771487.845</td>\n",
       "      <td>54735.783981</td>\n",
       "      <td>[9000.0, 2250.0, 4500.0, 6750.0, 3375.0, 5625....</td>\n",
       "      <td>[248757, 182654, 178309, 170360, 141832, 91165...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>days_delayed_payment</th>\n",
       "      <td>float64</td>\n",
       "      <td>2905</td>\n",
       "      <td>2404</td>\n",
       "      <td>-2884.0</td>\n",
       "      <td>8.787405e+00</td>\n",
       "      <td>3189.000</td>\n",
       "      <td>25.539900</td>\n",
       "      <td>[0.0, 1.0, 2.0, 3.0, 9.0, 4.0, 8.0, 6.0, 7.0, ...</td>\n",
       "      <td>[3146350, 525380, 507963, 459365, 454549, 4525...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                       DataType  #Nulls  #Uniques        Min          Mean  \\\n",
       "SK_ID_PREV                int64       0    997752  1000001.0  1.903365e+06   \n",
       "SK_ID_CURR                int64       0    339587   100001.0  2.784449e+05   \n",
       "NUM_INSTALMENT_VERSION  float64       0        65        0.0  8.566373e-01   \n",
       "NUM_INSTALMENT_NUMBER     int64       0       277        1.0  1.887090e+01   \n",
       "DAYS_INSTALMENT         float64       0      2922    -2922.0 -1.042270e+03   \n",
       "DAYS_ENTRY_PAYMENT      float64    2905      3039    -4921.0 -1.051114e+03   \n",
       "AMT_INSTALMENT          float64       0    902539        0.0  1.705091e+04   \n",
       "AMT_PAYMENT             float64    2905    944235        0.0  1.723822e+04   \n",
       "days_delayed_payment    float64    2905      2404    -2884.0  8.787405e+00   \n",
       "\n",
       "                                Max            Std  \\\n",
       "SK_ID_PREV              2843499.000  536202.905546   \n",
       "SK_ID_CURR               456255.000  102718.310411   \n",
       "NUM_INSTALMENT_VERSION      178.000       1.035216   \n",
       "NUM_INSTALMENT_NUMBER       277.000      26.664067   \n",
       "DAYS_INSTALMENT              -1.000     800.946284   \n",
       "DAYS_ENTRY_PAYMENT           -1.000     800.585883   \n",
       "AMT_INSTALMENT          3771487.845   50570.254429   \n",
       "AMT_PAYMENT             3771487.845   54735.783981   \n",
       "days_delayed_payment       3189.000      25.539900   \n",
       "\n",
       "                                                                top10 val  \\\n",
       "SK_ID_PREV              [2360056, 2592574, 1017477, 1449382, 1746731, ...   \n",
       "SK_ID_CURR              [145728, 296205, 453103, 189699, 186851, 17269...   \n",
       "NUM_INSTALMENT_VERSION  [1.0, 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, ...   \n",
       "NUM_INSTALMENT_NUMBER                     [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]   \n",
       "DAYS_INSTALMENT         [-120.0, -180.0, -150.0, -119.0, -149.0, -210....   \n",
       "DAYS_ENTRY_PAYMENT      [-91.0, -182.0, -154.0, -92.0, -245.0, -273.0,...   \n",
       "AMT_INSTALMENT          [9000.0, 2250.0, 4500.0, 6750.0, 3375.0, 5625....   \n",
       "AMT_PAYMENT             [9000.0, 2250.0, 4500.0, 6750.0, 3375.0, 5625....   \n",
       "days_delayed_payment    [0.0, 1.0, 2.0, 3.0, 9.0, 4.0, 8.0, 6.0, 7.0, ...   \n",
       "\n",
       "                                                                top10 cnt  \n",
       "SK_ID_PREV              [293, 279, 248, 243, 236, 223, 222, 220, 219, ...  \n",
       "SK_ID_CURR              [372, 350, 347, 344, 337, 336, 332, 324, 323, ...  \n",
       "NUM_INSTALMENT_VERSION  [8485004, 4082498, 620283, 237063, 55274, 4840...  \n",
       "NUM_INSTALMENT_NUMBER   [1004160, 985716, 968279, 943502, 880007, 8279...  \n",
       "DAYS_INSTALMENT         [11512, 11212, 11194, 11183, 11144, 11140, 111...  \n",
       "DAYS_ENTRY_PAYMENT      [13103, 13090, 13071, 12646, 12405, 12151, 119...  \n",
       "AMT_INSTALMENT          [254062, 179120, 174143, 173659, 149941, 96362...  \n",
       "AMT_PAYMENT             [248757, 182654, 178309, 170360, 141832, 91165...  \n",
       "days_delayed_payment    [3146350, 525380, 507963, 459365, 454549, 4525...  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "EDA.df_info(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['SK_ID_PREV', 'SK_ID_CURR', 'NUM_INSTALMENT_VERSION',\n",
       "       'NUM_INSTALMENT_NUMBER', 'DAYS_INSTALMENT', 'DAYS_ENTRY_PAYMENT',\n",
       "       'AMT_INSTALMENT', 'AMT_PAYMENT', 'days_delayed_payment'],\n",
       "      dtype='object')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ids = df.SK_ID_CURR.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ids1 = df[df.TARGET==1].SK_ID_CURR.unique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SK_ID_PREV</th>\n",
       "      <th>SK_ID_CURR</th>\n",
       "      <th>NUM_INSTALMENT_VERSION</th>\n",
       "      <th>NUM_INSTALMENT_NUMBER</th>\n",
       "      <th>DAYS_INSTALMENT</th>\n",
       "      <th>DAYS_ENTRY_PAYMENT</th>\n",
       "      <th>AMT_INSTALMENT</th>\n",
       "      <th>AMT_PAYMENT</th>\n",
       "      <th>days_delayed_payment</th>\n",
       "      <th>amt_ratio</th>\n",
       "      <th>amt_delta</th>\n",
       "      <th>days_weighted_delay</th>\n",
       "      <th>days_weighted_delay_tsw3</th>\n",
       "      <th>TARGET</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9813174</th>\n",
       "      <td>1870175</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>-15.0</td>\n",
       "      <td>-28.0</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>13.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>13.000000</td>\n",
       "      <td>12.890800</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813175</th>\n",
       "      <td>1870175</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>-45.0</td>\n",
       "      <td>-60.0</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>15.000000</td>\n",
       "      <td>14.730000</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813176</th>\n",
       "      <td>1870175</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>-75.0</td>\n",
       "      <td>-89.0</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>10712.160</td>\n",
       "      <td>14.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>14.000000</td>\n",
       "      <td>13.626200</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813177</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12</td>\n",
       "      <td>-624.0</td>\n",
       "      <td>-607.0</td>\n",
       "      <td>7898.625</td>\n",
       "      <td>7892.955</td>\n",
       "      <td>-17.0</td>\n",
       "      <td>0.999282</td>\n",
       "      <td>5.670</td>\n",
       "      <td>-16.987797</td>\n",
       "      <td>-13.894319</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813178</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>2.0</td>\n",
       "      <td>101</td>\n",
       "      <td>-608.0</td>\n",
       "      <td>-607.0</td>\n",
       "      <td>1350.000</td>\n",
       "      <td>1350.000</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>-1.000000</td>\n",
       "      <td>-0.817900</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813179</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11</td>\n",
       "      <td>-654.0</td>\n",
       "      <td>-649.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>0.999285</td>\n",
       "      <td>5.670</td>\n",
       "      <td>-4.996427</td>\n",
       "      <td>-4.023623</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813180</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>12</td>\n",
       "      <td>-624.0</td>\n",
       "      <td>-649.0</td>\n",
       "      <td>7898.625</td>\n",
       "      <td>5.670</td>\n",
       "      <td>25.0</td>\n",
       "      <td>0.000718</td>\n",
       "      <td>7892.955</td>\n",
       "      <td>0.017946</td>\n",
       "      <td>0.014452</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813181</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>10</td>\n",
       "      <td>-684.0</td>\n",
       "      <td>-679.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>0.999285</td>\n",
       "      <td>5.670</td>\n",
       "      <td>-4.996427</td>\n",
       "      <td>-3.978655</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813182</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>11</td>\n",
       "      <td>-654.0</td>\n",
       "      <td>-679.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>5.670</td>\n",
       "      <td>25.0</td>\n",
       "      <td>0.000715</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>0.017864</td>\n",
       "      <td>0.014225</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813183</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>10</td>\n",
       "      <td>-684.0</td>\n",
       "      <td>-709.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>5.670</td>\n",
       "      <td>25.0</td>\n",
       "      <td>0.000715</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>0.017864</td>\n",
       "      <td>0.014064</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813184</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9</td>\n",
       "      <td>-714.0</td>\n",
       "      <td>-709.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>0.999285</td>\n",
       "      <td>5.670</td>\n",
       "      <td>-4.996427</td>\n",
       "      <td>-3.933687</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813185</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>9</td>\n",
       "      <td>-714.0</td>\n",
       "      <td>-756.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>5.670</td>\n",
       "      <td>42.0</td>\n",
       "      <td>0.000715</td>\n",
       "      <td>7929.495</td>\n",
       "      <td>0.030011</td>\n",
       "      <td>0.023204</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813186</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>8</td>\n",
       "      <td>-744.0</td>\n",
       "      <td>-756.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>12.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>12.000000</td>\n",
       "      <td>9.278400</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813187</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>7</td>\n",
       "      <td>-774.0</td>\n",
       "      <td>-798.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>24.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>24.000000</td>\n",
       "      <td>18.254400</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813188</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>6</td>\n",
       "      <td>-804.0</td>\n",
       "      <td>-825.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>21.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>21.000000</td>\n",
       "      <td>15.802500</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813189</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5</td>\n",
       "      <td>-834.0</td>\n",
       "      <td>-848.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>14.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>14.000000</td>\n",
       "      <td>10.438400</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813190</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4</td>\n",
       "      <td>-864.0</td>\n",
       "      <td>-883.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>19.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>19.000000</td>\n",
       "      <td>13.966900</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813191</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>-894.0</td>\n",
       "      <td>-919.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>25.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>25.000000</td>\n",
       "      <td>18.107500</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813192</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>-924.0</td>\n",
       "      <td>-947.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>23.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>23.000000</td>\n",
       "      <td>16.465700</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9813193</th>\n",
       "      <td>1982773</td>\n",
       "      <td>357318</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>-954.0</td>\n",
       "      <td>-975.0</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>7935.165</td>\n",
       "      <td>21.0</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000</td>\n",
       "      <td>21.000000</td>\n",
       "      <td>14.857500</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         SK_ID_PREV  SK_ID_CURR  NUM_INSTALMENT_VERSION  \\\n",
       "9813174     1870175      357318                     1.0   \n",
       "9813175     1870175      357318                     1.0   \n",
       "9813176     1870175      357318                     1.0   \n",
       "9813177     1982773      357318                     1.0   \n",
       "9813178     1982773      357318                     2.0   \n",
       "9813179     1982773      357318                     1.0   \n",
       "9813180     1982773      357318                     1.0   \n",
       "9813181     1982773      357318                     1.0   \n",
       "9813182     1982773      357318                     1.0   \n",
       "9813183     1982773      357318                     1.0   \n",
       "9813184     1982773      357318                     1.0   \n",
       "9813185     1982773      357318                     1.0   \n",
       "9813186     1982773      357318                     1.0   \n",
       "9813187     1982773      357318                     1.0   \n",
       "9813188     1982773      357318                     1.0   \n",
       "9813189     1982773      357318                     1.0   \n",
       "9813190     1982773      357318                     1.0   \n",
       "9813191     1982773      357318                     1.0   \n",
       "9813192     1982773      357318                     1.0   \n",
       "9813193     1982773      357318                     1.0   \n",
       "\n",
       "         NUM_INSTALMENT_NUMBER  DAYS_INSTALMENT  DAYS_ENTRY_PAYMENT  \\\n",
       "9813174                      3            -15.0               -28.0   \n",
       "9813175                      2            -45.0               -60.0   \n",
       "9813176                      1            -75.0               -89.0   \n",
       "9813177                     12           -624.0              -607.0   \n",
       "9813178                    101           -608.0              -607.0   \n",
       "9813179                     11           -654.0              -649.0   \n",
       "9813180                     12           -624.0              -649.0   \n",
       "9813181                     10           -684.0              -679.0   \n",
       "9813182                     11           -654.0              -679.0   \n",
       "9813183                     10           -684.0              -709.0   \n",
       "9813184                      9           -714.0              -709.0   \n",
       "9813185                      9           -714.0              -756.0   \n",
       "9813186                      8           -744.0              -756.0   \n",
       "9813187                      7           -774.0              -798.0   \n",
       "9813188                      6           -804.0              -825.0   \n",
       "9813189                      5           -834.0              -848.0   \n",
       "9813190                      4           -864.0              -883.0   \n",
       "9813191                      3           -894.0              -919.0   \n",
       "9813192                      2           -924.0              -947.0   \n",
       "9813193                      1           -954.0              -975.0   \n",
       "\n",
       "         AMT_INSTALMENT  AMT_PAYMENT  days_delayed_payment  amt_ratio  \\\n",
       "9813174       10712.160    10712.160                  13.0   1.000000   \n",
       "9813175       10712.160    10712.160                  15.0   1.000000   \n",
       "9813176       10712.160    10712.160                  14.0   1.000000   \n",
       "9813177        7898.625     7892.955                 -17.0   0.999282   \n",
       "9813178        1350.000     1350.000                  -1.0   1.000000   \n",
       "9813179        7935.165     7929.495                  -5.0   0.999285   \n",
       "9813180        7898.625        5.670                  25.0   0.000718   \n",
       "9813181        7935.165     7929.495                  -5.0   0.999285   \n",
       "9813182        7935.165        5.670                  25.0   0.000715   \n",
       "9813183        7935.165        5.670                  25.0   0.000715   \n",
       "9813184        7935.165     7929.495                  -5.0   0.999285   \n",
       "9813185        7935.165        5.670                  42.0   0.000715   \n",
       "9813186        7935.165     7935.165                  12.0   1.000000   \n",
       "9813187        7935.165     7935.165                  24.0   1.000000   \n",
       "9813188        7935.165     7935.165                  21.0   1.000000   \n",
       "9813189        7935.165     7935.165                  14.0   1.000000   \n",
       "9813190        7935.165     7935.165                  19.0   1.000000   \n",
       "9813191        7935.165     7935.165                  25.0   1.000000   \n",
       "9813192        7935.165     7935.165                  23.0   1.000000   \n",
       "9813193        7935.165     7935.165                  21.0   1.000000   \n",
       "\n",
       "         amt_delta  days_weighted_delay  days_weighted_delay_tsw3  TARGET  \n",
       "9813174      0.000            13.000000                 12.890800     1.0  \n",
       "9813175      0.000            15.000000                 14.730000     1.0  \n",
       "9813176      0.000            14.000000                 13.626200     1.0  \n",
       "9813177      5.670           -16.987797                -13.894319     1.0  \n",
       "9813178      0.000            -1.000000                 -0.817900     1.0  \n",
       "9813179      5.670            -4.996427                 -4.023623     1.0  \n",
       "9813180   7892.955             0.017946                  0.014452     1.0  \n",
       "9813181      5.670            -4.996427                 -3.978655     1.0  \n",
       "9813182   7929.495             0.017864                  0.014225     1.0  \n",
       "9813183   7929.495             0.017864                  0.014064     1.0  \n",
       "9813184      5.670            -4.996427                 -3.933687     1.0  \n",
       "9813185   7929.495             0.030011                  0.023204     1.0  \n",
       "9813186      0.000            12.000000                  9.278400     1.0  \n",
       "9813187      0.000            24.000000                 18.254400     1.0  \n",
       "9813188      0.000            21.000000                 15.802500     1.0  \n",
       "9813189      0.000            14.000000                 10.438400     1.0  \n",
       "9813190      0.000            19.000000                 13.966900     1.0  \n",
       "9813191      0.000            25.000000                 18.107500     1.0  \n",
       "9813192      0.000            23.000000                 16.465700     1.0  \n",
       "9813193      0.000            21.000000                 14.857500     1.0  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp = df[df.SK_ID_CURR==np.random.choice(ids1)]\n",
    "tmp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>SK_ID_PREV</th>\n",
       "      <th>SK_ID_CURR</th>\n",
       "      <th>NUM_INSTALMENT_VERSION</th>\n",
       "      <th>NUM_INSTALMENT_NUMBER</th>\n",
       "      <th>DAYS_INSTALMENT</th>\n",
       "      <th>DAYS_ENTRY_PAYMENT</th>\n",
       "      <th>AMT_INSTALMENT</th>\n",
       "      <th>AMT_PAYMENT</th>\n",
       "      <th>days_delayed_payment</th>\n",
       "      <th>amt_ratio</th>\n",
       "      <th>amt_delta</th>\n",
       "      <th>days_weighted_delay</th>\n",
       "      <th>days_weighted_delay_tsw3</th>\n",
       "      <th>TARGET</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>3779142</th>\n",
       "      <td>2762719</td>\n",
       "      <td>199463</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5</td>\n",
       "      <td>-1994.0</td>\n",
       "      <td>-2001.0</td>\n",
       "      <td>8189.46</td>\n",
       "      <td>8189.46</td>\n",
       "      <td>7.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>2.7979</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3779143</th>\n",
       "      <td>2762719</td>\n",
       "      <td>199463</td>\n",
       "      <td>1.0</td>\n",
       "      <td>4</td>\n",
       "      <td>-2024.0</td>\n",
       "      <td>-2063.0</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>39.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>39.0</td>\n",
       "      <td>14.8629</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3779144</th>\n",
       "      <td>2762719</td>\n",
       "      <td>199463</td>\n",
       "      <td>1.0</td>\n",
       "      <td>3</td>\n",
       "      <td>-2054.0</td>\n",
       "      <td>-2089.0</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>35.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>35.0</td>\n",
       "      <td>13.0655</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3779145</th>\n",
       "      <td>2762719</td>\n",
       "      <td>199463</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2</td>\n",
       "      <td>-2084.0</td>\n",
       "      <td>-2136.0</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>52.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>52.0</td>\n",
       "      <td>18.6784</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3779146</th>\n",
       "      <td>2762719</td>\n",
       "      <td>199463</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1</td>\n",
       "      <td>-2114.0</td>\n",
       "      <td>-2136.0</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>4194.18</td>\n",
       "      <td>22.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>22.0</td>\n",
       "      <td>7.9024</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         SK_ID_PREV  SK_ID_CURR  NUM_INSTALMENT_VERSION  \\\n",
       "3779142     2762719      199463                     2.0   \n",
       "3779143     2762719      199463                     1.0   \n",
       "3779144     2762719      199463                     1.0   \n",
       "3779145     2762719      199463                     1.0   \n",
       "3779146     2762719      199463                     1.0   \n",
       "\n",
       "         NUM_INSTALMENT_NUMBER  DAYS_INSTALMENT  DAYS_ENTRY_PAYMENT  \\\n",
       "3779142                      5          -1994.0             -2001.0   \n",
       "3779143                      4          -2024.0             -2063.0   \n",
       "3779144                      3          -2054.0             -2089.0   \n",
       "3779145                      2          -2084.0             -2136.0   \n",
       "3779146                      1          -2114.0             -2136.0   \n",
       "\n",
       "         AMT_INSTALMENT  AMT_PAYMENT  days_delayed_payment  amt_ratio  \\\n",
       "3779142         8189.46      8189.46                   7.0        1.0   \n",
       "3779143         4194.18      4194.18                  39.0        1.0   \n",
       "3779144         4194.18      4194.18                  35.0        1.0   \n",
       "3779145         4194.18      4194.18                  52.0        1.0   \n",
       "3779146         4194.18      4194.18                  22.0        1.0   \n",
       "\n",
       "         amt_delta  days_weighted_delay  days_weighted_delay_tsw3  TARGET  \n",
       "3779142        0.0                  7.0                    2.7979     1.0  \n",
       "3779143        0.0                 39.0                   14.8629     1.0  \n",
       "3779144        0.0                 35.0                   13.0655     1.0  \n",
       "3779145        0.0                 52.0                   18.6784     1.0  \n",
       "3779146        0.0                 22.0                    7.9024     1.0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp = df[df.SK_ID_CURR==np.random.choice(ids1)]\n",
    "tmp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
